const express = require("express")
const app = express()
app.use(express.static('./web'))
app.use(express.urlencoded({extended:false}))
app.use(express.json())
app.get("/check",(req,res)=>{
    const { name } = req.query
    const arr = ["zs","ls","ww","xx"]
    const result = arr.includes(name)
    if(!result){
        res.send({success:true,msg:"用户名可用"})
    }else{
        res.send({success:false,msg:"用户名不可用"})
    }
})
app.post("/check",(req,res)=>{
    const { name } = req.body
    const arr = ["zs","ls","ww","xx"]
    const result = arr.includes(name)
    if(!result){
        res.send({success:true,msg:"用户名可用"})
    }else{
        res.send({success:false,msg:"用户名不可用"})
    }
})
app.listen(5000,(err)=>{
    if(err) console.log("服务器创建失败")
    else console.log("服务器创建成功")
})